#version 330
layout(location = 0) in vec3 vPosition;
layout(location = 1) in vec3 vNormal;
layout(location = 2) in vec3 vColor;

uniform int useColor;
uniform vec4 veClipPlane; //ax+by+cz+d = 0
uniform mat4 matCamera, matModelToWorld, matProj;
uniform vec3 color;
float gl_ClipDistance[1];

out vec4 pntOut;
out vec4 vs_fs_color;
void main()
{
	vec4 pnt = vec4(vPosition, 1);
	
	gl_Position = matProj*matCamera*matModelToWorld*pnt;
	pntOut = gl_Position;
	if(useColor == 1)
	{
		vs_fs_color = vec4(color,1);
	}
	else
	{
		vs_fs_color = vec4(vColor, 1);
	}
	
vec3 vePntWorld = vec3(matModelToWorld*pnt);
gl_ClipDistance[0] =dot(vePntWorld, vec3(veClipPlane)) + veClipPlane.w;

}